//
//  ZZZXGoodsAnalysisDetailVC.m
//  新项目
//
//  Created by liGordon on 17/3/9.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "ZZZXGoodsAnalysisDetailVC.h"
#import "ZZZXGoodsAnalysisDetailCell.h"
static NSString * identifier = @"goodsAnalysisDetailCell";
@interface ZZZXGoodsAnalysisDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *menuTable;

@end

@implementation ZZZXGoodsAnalysisDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _menuTable.delegate = self;
    _menuTable.dataSource = self;
    self.title = @"滞销商品分析";
    [_menuTable registerNib:[UINib nibWithNibName:@"ZZZXGoodsAnalysisDetailCell" bundle:nil]forCellReuseIdentifier:identifier];
    _menuTable.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.flag==1) {
          return 7;
    }else if (self.flag==2)
    {
        return 5;
    
    }else if (self.flag==3||self.flag==5)
    {
        return 9;
        
    }else if (self.flag==4)
    {
        return 8;
    }
  else
      return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZZZXGoodsAnalysisDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    //根据不同类型进行判别
    [self jugeFlagWithTableView:indexPath andCell:cell];

   
    return cell;
}
// 判别如何展示
-(void)jugeFlagWithTableView:(NSIndexPath *)indexPath  andCell:(ZZZXGoodsAnalysisDetailCell *)cell
{
    if (self.flag==1) {
        if (indexPath.row == 0) {
            cell.titleName.text = @"配件名称";
            cell.detailName.text = self.dic[@"PartsName"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"配件编码";
            cell.detailName.text =self.dic[@"PartsCode"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"适用车型";
            cell.detailName.text = self.dic[@"CarModelName"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"单位";
            cell.detailName.text =self.dic[@"UnitName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"数量";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"SumNumber"] integerValue]];
        }else if (indexPath.row == 5){
            cell.titleName.text = @"平均单价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"AvgMoney"] floatValue]];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"金额";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"SumMoney"] floatValue]];
        }else if (indexPath.row == 7){
            cell.titleName.text = @"最后销售/入库时间";
            cell.detailName.text =self.dic[@"CreationTime"];}
        
    }else if (self.flag==2)
    {
        
        if (indexPath.row == 0) {
        cell.titleName.text = @"供应商名称";
        cell.detailName.text = self.dic[@"SupplierName"];
        }else if (indexPath.row == 1){
        cell.titleName.text = @"退货数量";
        cell.detailName.text =[NSString stringWithFormat:@"%.2lf",[self.dic[@"RGSumNum"] floatValue]] ;
    }else if (indexPath.row == 2){
        cell.titleName.text = @"退货次数";
        cell.detailName.text =[NSString stringWithFormat:@"%ld次",[self.dic[@"Frequency"] integerValue]];
    }else if (indexPath.row == 3){
        cell.titleName.text = @"总退货金额";
        cell.detailName.text =[NSString stringWithFormat:@"¥%ld",[self.dic[@"RGMoney"] integerValue]];
    }
    }else if (self.flag==3)
    {
        
        if (indexPath.row == 0) {
            cell.titleName.text = @"配件名称";
            cell.detailName.text = self.dic[@"PartsName"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"配件编码";
            cell.detailName.text =self.dic[@"PartsCode"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"适用车型";
            cell.detailName.text = self.dic[@"CarModelName"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"单位";
            cell.detailName.text =self.dic[@"UnitName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"数量";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"SumNumber"] integerValue]];
        }else if (indexPath.row == 5){
            cell.titleName.text = @"平均进价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"AvgBidMoney"] floatValue]];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"平均售价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"AvgMoney"] floatValue]];
        }
        
        else if (indexPath.row == 7){
            cell.titleName.text = @"售价合计";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"SumMoney"] floatValue]];
        }
    
    
    
    }else if (self.flag==4)
    {
        if (indexPath.row == 0) {
            cell.titleName.text = @"配件名称";
            cell.detailName.text = self.dic[@"PartsName"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"配件编码";
            cell.detailName.text =self.dic[@"PartsCode"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"适用车型";
            cell.detailName.text = self.dic[@"CarModelName"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"单位";
            cell.detailName.text =self.dic[@"UnitName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"数量";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"SumNumber"] integerValue]];
        }else if (indexPath.row == 5){
            cell.titleName.text = @"最低进价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"MinBidMoney"] floatValue]];
        }
        else if (indexPath.row == 6){
            cell.titleName.text = @"最高进价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"MaxBidMoney"] floatValue]];
        }else if (indexPath.row == 7){
            cell.titleName.text = @"平均进价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"AvgBidMoney"] floatValue]];
        }
    
    
    }else if (self.flag==5)
    {
        if (indexPath.row == 0) {
            cell.titleName.text = @"配件名称";
            cell.detailName.text = self.dic[@"PartsName"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"配件编码";
            cell.detailName.text =self.dic[@"PartsCode"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"适用车型";
            cell.detailName.text = self.dic[@"CarModelName"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"单位";
            cell.detailName.text =self.dic[@"UnitName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"总销售数量";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"SumNumber"] integerValue]];
        }else if (indexPath.row == 5){
            cell.titleName.text = @"最低售价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"MinMoney"] floatValue]];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"最低销售次数";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"MinNum"] integerValue]];
        }
        
        else if (indexPath.row == 7){
            cell.titleName.text = @"最高售价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"MaxMoney"] floatValue]];
        }else if (indexPath.row == 8){
            cell.titleName.text = @"最高销售次数";
            cell.detailName.text =[NSString stringWithFormat:@"%ld",[self.dic[@"MaxNum"] integerValue]];
        }else if (indexPath.row == 9){
            cell.titleName.text = @"销售均价";
            cell.detailName.text =[NSString stringWithFormat:@"¥%@",self.dic[@"AvgMoney"]];
        }

    
    
    }

}


@end
